package com.shenzhenai.module_design_partterns.class2;

import com.shenzhenai.module_design_partterns.class1.CashNormal;
import com.shenzhenai.module_design_partterns.class1.CashRebate;
import com.shenzhenai.module_design_partterns.class1.CashReturn;

/**
 * @author huangzehui
 * @date 2025/8/8 13:38 周五
 * @description 2. 策略模式
 * https://www.bilibili.com/video/BV1et3MzxEgJ?spm_id_from=333.788.videopod.episodes&vd_source=e07cc8cc94eb22bd76722071b03cd199&p=2
 */
public class MainApp {

    public static void main(String[] args) {

        double price = 1;
        int count = 2;
        int type = 3;

        CashContext cc =  new CashContext(getDisCountText(type));
        double result = cc.getResult(price * count);
        System.out.println("单价: " + price + ", 数量：" + count + ", 折扣：" + getDisCountText(type) + ", 费用：" + result);
    }


    private static String getDisCountText(int type) {
        String disCountText = "";
        switch (type) {
            case 1:
                disCountText = "正常消费";
                break;
            case 2:
                disCountText = "满300返100";
                break;
            case 3:
                disCountText = "打8折";
                break;
            default:
                break;
        }
        return disCountText;
    }
}
